import sys
sys.path.append(".")
import tensorflow as tf
import model_zoo.keras.inception_v3_change_layer as inception_v3
import numpy as np
import tensorflow.keras.layers as layers

tf_23_layer_names = ["input", "conv2d_1", "conv2d_2", "conv2d_3", "max_pooling2d_1", "conv2d_4", "conv2d_5","max_pooling2d_2","mixed0",
                   "mixed1", "mixed2", "mixed3", "mixed4", "mixed5", "mixed6", "mixed7", "mixed8", "mixed9", "mixed10"]
tf_14_layer_names = ["input", "Conv2d_1a_3x3", "Conv2d_2a_3x3", "Conv2d_2b_3x3",
                       "MaxPool_3a_3x3", "Conv2d_3b_1x1", "Conv2d_4a_3x3",
                       "MaxPool_5a_3x3", "Mixed_5b", "Mixed_5c",
                       "Mixed_5d", "Mixed_6a", "Mixed_6b", "Mixed_6c",
                       "Mixed_6d", "Mixed_6e", "Mixed_7a",
                       "Mixed_7b", "Mixed_7c"]
fig_names = ["guitar","cat", "scorpion","dog", "pig"]
model_name = "inception_v3"
for k in range(len(tf_14_layer_names)):
    for fig_name in fig_names:
        source_file = "middle_data/"+model_name+"/"+tf_14_layer_names[k]+"_"+fig_name+".npy"
        target_file = "middle_data_tf22/"+model_name+"/"+tf_23_layer_names[k]+"_"+fig_name+".npy"
        data = np.load(source_file)
        np.save(target_file,data)
'''
input_basic = np.load("middle_data/inception_v3/input_guitar.npy")
input_data = tf.constant(np.asarray(np.expand_dims(input_basic, axis=0),dtype=np.float32))

middle_basic = np.load("middle_data/inception_v3/Conv2d_1a_3x3_guitar.npy")
middle_data = tf.constant(np.asarray(np.expand_dims(middle_basic, axis=0),dtype=np.float32))
inception = inception_v3.InceptionV3(partition_layer='conv2d',input_shape=middle_basic.shape)
# for layer in inception.layers:
#    print(layer.name)

print(np.argmax(inception(middle_data)[0]))
'''
